package com.cuitrip.util;

import android.content.Context;
import android.support.annotation.ColorInt;
import android.support.annotation.ColorRes;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.style.AbsoluteSizeSpan;
import android.text.style.ForegroundColorSpan;
import android.text.style.RelativeSizeSpan;

import com.cuitrip.service.R;
import com.lab.rtenvironment.AppCoreRuntime;

/**
 * Created by ak on 15/9/22.
 */
public class SpanUtil {

    /**
     * 获取首部为特殊符号
     * @param text
     * @return
     */
    public static SpannableString getSizeSpan(float size, String text){
        SpannableString ss = new SpannableString(text);
        ss.setSpan(new RelativeSizeSpan(size), 0, 1, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
        ss.setSpan(new ForegroundColorSpan(AppCoreRuntime.context.getResources().getColor(R.color.ganshi_ded8d7)), 0, text.length(),Spanned.SPAN_INCLUSIVE_INCLUSIVE);
        return ss;
    }

    /**
     * 获取颜色span
     * @param text
     * @return
     */
    public static SpannableString getColorSpanString(int color, CharSequence text){
        SpannableString ss = new SpannableString(text);
        if (text.length() != 0){
            ss.setSpan(new ForegroundColorSpan(color), 0, text.length(),Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
        }
        return ss;
    }

    public static SpannableString setSize(SpannableString spannableString, float size){
        spannableString.setSpan(new RelativeSizeSpan(size), 0, spannableString.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
        return spannableString;
    }


}
